<template>
  <div>
    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      columnsRef="partPartPurchasePurchaseOrderCheckPurchaseOrderPart"
      :datakey="'rows'"
      :isSelectColumn="false"
      :onColumnsChange="columns => (this.columns = columns)"
    />
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getPurchaseOrderPart } from '@/api/part/partPurchase/purchaseOrderCheck';
export default {
  name: 'purchaseOrderPart',
  mixins: [dictionary],
  props: ['id'],
  data() {
    return {
      columns: this.createTableColumns(),
      fetchApi: getInfo,
      fetchParams: { xhrAbort: false }
    };
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '配件代码',
          dataIndex: 'partNo'
        },
        {
          title: '配件名称',
          dataIndex: 'partName'
        },
        {
          title: '数量',
          dataIndex: 'inQuantity',
          precision: 2
        },
        {
          title: '到货数量',
          dataIndex: '2'
        },
        {
          title: '本次数量',
          dataIndex: '3'
        },
        {
          title: '计量单位',
          dataIndex: 'UNIT_NAME'
        },
        {
          title: '库区',
          dataIndex: 'receivedNumber'
        },
        {
          title: '库位',
          dataIndex: 'bankFlowNumber'
        },
        {
          title: '备注',
          dataIndex: 'remark'
        },
        {
          title: '单价',
          dataIndex: 'costPrice',
          precision: 2
        },
        {
          title: '金额',
          dataIndex: 'netAmount',
          precision: 2
        },
        {
          title: '车型',
          dataIndex: 'model'
        }
      ];
    },
    async getInfo() {
      return await getPurchaseOrderPart(this.id);
    }
  }
};
</script>
